/*    */ package org.yaukie.auth.handler;
/*    */ 
/*    */ import com.alibaba.fastjson.JSON;
/*    */ import java.io.IOException;
/*    */ import java.io.Serializable;
/*    */ import javax.servlet.ServletException;
/*    */ import javax.servlet.http.HttpServletRequest;
/*    */ import javax.servlet.http.HttpServletResponse;
/*    */ import org.slf4j.Logger;
/*    */ import org.slf4j.LoggerFactory;
/*    */ import org.springframework.beans.factory.annotation.Autowired;
/*    */ import org.springframework.security.core.Authentication;
/*    */ import org.springframework.security.web.authentication.logout.LogoutSuccessHandler;
/*    */ import org.springframework.stereotype.Component;
/*    */ import org.yaukie.auth.constant.AjaxResult;
/*    */ import org.yaukie.auth.constant.AuthCons;
/*    */ import org.yaukie.auth.entity.LoginUser;
/*    */ import org.yaukie.auth.service.api.TokenHandlerService;
/*    */ import org.yaukie.base.redis.RedisOrMapCache;
/*    */ import org.yaukie.base.util.ServletUtils;
/*    */ import org.yaukie.base.util.StringTools;
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ @Component
/*    */ public class LoginOutSuccessHandler
/*    */   implements LogoutSuccessHandler, Serializable
/*    */ {
/* 33 */   private static final Logger log = LoggerFactory.getLogger(LoginOutSuccessHandler.class);
/*    */ 
/*    */   
/*    */   @Autowired
/*    */   private RedisOrMapCache redisOrMapCache;
/*    */   
/*    */   @Autowired
/*    */   private TokenHandlerService tokenHandlerService;
/*    */ 
/*    */   
/*    */   public void onLogoutSuccess(HttpServletRequest request, HttpServletResponse response, Authentication authentication) throws IOException, ServletException {
/* 44 */     if (log.isInfoEnabled()) {
/* 45 */       log.info("系统模块{}执行注销处理.....", getClass().getSimpleName());
/*    */     }
/* 47 */     LoginUser loginUser = this.tokenHandlerService.getLoginUser(request);
/* 48 */     int code = AuthCons.Login.LOGIN_OUT.getCode();
/* 49 */     String msg = AuthCons.Login.LOGIN_OUT.getDes();
/* 50 */     if (StringTools.isNotNull(loginUser)) {
/* 51 */       this.tokenHandlerService.delLoginUser(loginUser.getToken());
/*    */     }
/* 53 */     ServletUtils.renderString(response, JSON.toJSONString(AjaxResult.error(code, msg)));
/*    */   }
/*    */ }


/* Location:              /Users/rex/Desktop/x-common-auth-1.0.0-SNAPSHOT.jar!/org/yaukie/auth/handler/LoginOutSuccessHandler.class
 * Java compiler version: 8 (52.0)
 * JD-Core Version:       1.0.7
 */